<template>
	<view class="page" :style="{ 'min-height': h + 'px' }">
		<image class="bg_img" src="https://i.ringzle.com/file/20240129/3931d06eaa3346c9955aa7e5e535a95b.png"
			mode="widthFix"></image>
		<view class="account" :style="{ 'margin-top': (mt + 5) + 'px' }">
			<view class="a_left">
				<view class="al_avatar" @tap="toLogin">
					<image :src="avatar"></image>
				</view>
				<view class="al_name_edit">
					<text>{{ name }}</text>
					<view class="ane_edit" @tap="toTurn('/pagesMy/handerUser/handerUser', true)">
						<text>编辑</text>
						<image src="https://i.ringzle.com/file/20240129/e824a765b6c24ac6aafbb49b12c23aa9.png"></image>
					</view>
				</view>
			</view>
			<view class="a_right" @tap="toTurn('/pagesTaxi/onlineCustomers/onlineCustomers', true)">
				<image src="https://fsy.shengsi.gov.cn/file/20240717/52a655ea83af4cd9aa731b984a1e3d43.png"></image>
				<view>在线客服</view>
			</view>
		</view>
		<view class="nums box">
			<view @tap="toTurn('/pagesMy/coupon/index', true)">
				<text class="num">{{ coupons }}</text>
				<text>优惠券</text>
			</view>
			<view @tap="toTurn('', true)">
				<text class="num">{{ points }}</text>
				<text>积分</text>
			</view>
			<view @tap="toTurn('/pagesMy/collection/collection', true)">
				<text class="num">{{ collects }}</text>
				<text>收藏</text>
			</view>
			<view @tap="toTurn('/pagesMy/ThumbsList/ThumbsList', true)">
				<text class="num">{{ upvotes }}</text>
				<text>点赞</text>
			</view>
		</view>
		<!-- <view class="wallet box">
			<view class="w_left">
				<view class="wl_top">
					<image src="https://i.ringzle.com/file/20240129/60f0d414e1494b8a9feeef2a8e627934.png"></image>
					<text>钱包余额</text>
				</view>
				<view class="wl_price"><span class="wlp_span">￥</span><text>{{ price.toFixed(2) }}</text></view>
			</view>
			<view class="w_right" @tap="toTurn('/pagesMy/wallet/index', true)">充值/提现</view>
		</view> -->
		<view class="orders box">
			<view class="o_title">
				<text>我的订单</text>
				<view class="ot_all" @tap="toTurn('/pagesMy/order/myOrder', true)">
					<!-- <view class="ot_all" @tap="toToast"> -->
					<text>全部订单</text>
					<image src="@/static/index/steamerTicket/icon_yjt.png"></image>
				</view>
			</view>
			<view class="o_menus">
				<view v-for="(item, index) in orderMenus" :key="index"
					@tap="toTurn('/pagesMy/order/index?type=' + item.type, true)">
					<image :src="item.img"></image>
					<text>{{ item.text }}</text>
				</view>
			</view>
		</view>
		<view class="services box">
			<text class="s_title">更多服务</text>
			<view class="s_more">
				<u-scroll-list indicatorColor="#EFEFEF" indicatorActiveColor="#32C4B9">
					<view class="scroll-list" :style="{ 'width': ((w - 30) * 2) + 'px' }">
						<view class="sm_card" :style="{ 'width': (w - 30) + 'px' }">
							<view v-for="(item, index) in serviceMenus1" :key="index" @tap="toTurn(item.path, item.login)">
								<image :src="item.img"></image>
								<text>{{ item.text }}</text>
							</view>
						</view>
						<view class="sm_card" :style="{ 'width': (w - 30) + 'px' }">
							<view v-for="(item, index) in serviceMenus2" :key="index" @tap="toTurn(item.path, item.login, item.text)">
								<image :src="item.img"></image>
								<text>{{ item.text }}</text>
							</view>
						</view>
					</view>
				</u-scroll-list>
			</view>
		</view>
		<Tabbar :tabbarIndex="4" v-if="!elderVersion"></Tabbar>
		<!-- 关怀版 -->
		<Tabbar2 :tabbarIndex="2" v-else></Tabbar2>
		<GetPhoneNumber ref="phoneNumber" @loginSuccess="loginSuccess"></GetPhoneNumber>
	</view>
</template>

<script>
import Tabbar from '@/compoments/Tabbar/tabbar.vue'
import Tabbar2 from '@/compoments/Tabbar/tabbar2.vue'
import GetPhoneNumber from '@/compoments/Getphonenumber/index.vue'
export default {
	name: 'my',
	components: {
		Tabbar,
		Tabbar2,
		GetPhoneNumber
	},
	data() {
		return {
			elderVersion: uni.getStorageSync('elderVersion') || 0,
			h: uni.getSystemInfoSync().windowHeight,
			w: uni.getSystemInfoSync().windowWidth,
			mt: uni.getSystemInfoSync().statusBarHeight + 44,
			avatar: 'https://fsy.shengsi.gov.cn/file/20240730/7ead48306a1a49e598f7bb81a28c704f.png',
			name: '游客',
			coupons: 0, //优惠券数量
			points: 0, //积分数
			collects: 0, //收藏数
			upvotes: 0, //点赞数
			price: 0, //钱包余额
			orderMenus: [ //type:1 待支付、2 待使用、3 待评价、4 退款/售后
				{
					type: 1,
					img: 'https://i.ringzle.com/file/20240129/818fa751cf8d4772ac1cf818522a7f54.png',
					text: '待支付'
				},
				{
					type: 2,
					img: 'https://i.ringzle.com/file/20240129/c4ef5f92f5274dbe9e281ad509571fc3.png',
					text: '待使用'
				},
				{
					type: 3,
					img: 'https://i.ringzle.com/file/20240129/2a73e5e9afcf4d759b31e5332a21d012.png',
					text: '待评价'
				},
				{
					type: 4,
					img: 'https://i.ringzle.com/file/20240129/f3fd049aaffb4768aa115572851a2bb1.png',
					text: '退款/售后'
				}
			],
			serviceMenus1: [{
				img: 'https://i.ringzle.com/file/20240228/49e94894ce5145e7b8776ace8b7df695.png',
				text: '浏览记录',
				path: '/pagesMy/browsingHistory/index',
				login: true
			}, {
				img: 'https://i.ringzle.com/file/20240129/e32aed3180e94a9da7fea713dca26153.png',
				text: '我的行程',
				path: '/pagesTrip/custom-travel/index',
				login: true
			},
			{
				img: 'https://i.ringzle.com/file/20240129/01220b6430f44d67b5d60fb8277cc62e.png',
				text: '常用旅客',
				path: '/pagesMy/commonInformation/index?type=my',
				login: true
			},
			{
				img: 'https://i.ringzle.com/file/20240319/f73486fec8594ca09605a6bef5805588.png',
				text: '每日菜价',
				path: '/pagesMy/DailyPrice/DailyPrice',
				login: false
			},
			// {
			// 	img:'https://i.ringzle.com/file/20240129/8149c444f355404eb2eea4581fad0a8a.png',
			// 	text:'我的打卡',
			// 	path:'/pagesMy/myclockin/myclockin',
			// 	login:true
			// },
			{
				img: 'https://i.ringzle.com/file/20240129/b25e7b2cba904c3b8502d51b5aaec680.png',
				text: '车辆管理',
				path: '/pagesMy/vehicleManagement/index',
				login: true
			},
			// {
			// 	img:'https://i.ringzle.com/file/20240129/ceddcd60b1f448e7b24cf2f0da66c71a.png',
			// 	text:'我的评论',
			// 	path:'/pagesMy/comment/comment',
			// 	login:true
			// },
			{
				img: 'https://i.ringzle.com/file/20240129/44eaf11703404d08a4c06d3634b46bfb.png',
				text: '我的发布',
				path: '/pagesMy/publish/index',
				login: true
			},
			{
				img: 'https://i.ringzle.com/file/20240129/30333c2e35414cfb8f91f7c3289c58f3.png',
				text: '开发票',
				path: '/pagesMy/invoice/index',
				login: true
			},
			// {
			// 	img:'https://i.ringzle.com/file/20240129/f92177064a5a4cdab1396559fe6f58b5.png',
			// 	text:'意见反馈',
			// 	path:'/pagesMy/complaintFeedback/dataList',
			// 	login:true
			// },
			// {
			// 	img: 'https://i.ringzle.com/file/20240129/43dd0f31c85b484cbebf93bcf3949d7e.png',
			// 	text: '常用电话',
			// 	path: '/pagesMy/regularTelephone/index',
			// 	login: false
			// },
			{
				img: 'https://i.ringzle.com/file/20240129/5671966edea742bd85e885738b2d552b.png',
				text: '我的预约',
				path: '/pagesMy/culturalTour/culturalTour',
				login: true
			}
			],
			serviceMenus2: [
				// {
				// 	img:'https://i.ringzle.com/file/20240129/b25e7b2cba904c3b8502d51b5aaec680.png',
				// 	text:'车辆管理',
				// 	path:'/pagesMy/vehicleManagement/index',
				// 	login:true
				// },
				// {
				// 	img:'https://i.ringzle.com/file/20240129/43dd0f31c85b484cbebf93bcf3949d7e.png',
				// 	text:'常用电话',
				// 	path:'/pagesMy/regularTelephone/index',
				// 	login:false
				// },
				{
					img: 'https://i.ringzle.com/file/20240129/f92177064a5a4cdab1396559fe6f58b5.png',
					text: '意见反馈',
					path: '/pagesMy/complaintFeedback/dataList',
					login: true
				},
				{
					img: 'https://i.ringzle.com/file/20240129/9673f59a07504334baabbf6385b2bea5.png',
					text: '用户协议',
					path: '/pagesTrip/Useragreement/Useragreement',
					login: false
				},

				{
					img: 'https://i.ringzle.com/file/20240129/b6bf1f69ba1e4b2cbb48841391be75ea.png',
					text: '商家入驻',
					path: '/pagesMy/merchantOccupancyApplication/select',
					login: true
				},
				{
					img: 'https://i.ringzle.com/file/20240129/5d48184b74a54283bcefb932d1b69e69.png',
					text: '其他功能',
					path: '/pagesMy/other/index',
					login: false
				},
				{
					img: 'https://i.ringzle.com/file/20240605/6ab3b20c272a45d590cd5b53a38562df.png',
					text: '版本切换',
					path: '/pages/my/index2',
					login: false
				},
			]
		}
	},
	onLoad() {
		if (this.elderVersion == 1) {
			uni.redirectTo({
				url: '/pages/index/index2'
			})
		} else {
			this.getUserInfo();
		}
	},
	onShow() {
		if (this.elderVersion == 1) {
			uni.redirectTo({
				url: '/pages/index/index2'
			})
		} else {
			this.getUserInfo();
		}
	},
	methods: {
		toLogin() {
			this.$login().then(res => {
				if (res === 0) return
				else this.$refs['phoneNumber'].show = true;
			})
		},
		toTurn(url, login, text) { //login 是否需要验证登录跳转
			if (text == '版本切换') {
				uni.setStorageSync('elderVersion', 1);
			}
			if (!url) return this.$showToast('正在开发中...');
			if (login) {
				this.$login().then(res => {
					if (res === 0) {
						uni.navigateTo({
							url
						});
					} else this.$refs['phoneNumber'].show = true;
				})
			} else {
				uni.navigateTo({
					url
				});
			}
		},
		toToast() {
			this.$showToast('正在开发中...');
		},
		getUserInfo() {
			if (uni.getStorageSync('userInfo')) {
				this.name = JSON.parse(uni.getStorageSync('userInfo')).realName;
				this.avatar = JSON.parse(uni.getStorageSync("userInfo")).headUrl;
				//获取点赞收藏数
				this.getDzScNum();
				//获取钱包余额
				// this.getWalletMoney();
				this.getCouponNum();
			}
		},
		//登录成功回调事件
		loginSuccess() {
			this.getUserInfo();
		},
		getDzScNum() {
			this.$api.get('/api/likeAndCare/num').then(res => {
				if (res.data.code === 0) {
					this.upvotes = res.data.data.likeNum;
					this.collects = res.data.data.careNum;
				} else this.$showModal(res.data.msg);
			})
		},
		getWalletMoney() {
			this.$api.get('/api/userWalletInfo/getOne').then(res => {
				if (res.data.code === 0) {
					this.price = +res.data.data.walletAmount || 0;
				} else this.$showModal(res.data.msg);
			})
		},
		getCouponNum() {
			this.$api.get('/sys/discountCoupon/userCouponNum').then(res => {
				if (res.data.code === 0) {
					this.coupons = res.data.data;
				} else this.$showModal(res.data.msg);
			})
		},
	}
}
</script>

<style scoped lang="less">
.page {
	background: #F5F8FA;
	padding-bottom: 256rpx;
	box-sizing: border-box;

	.bg_img {
		width: 100%;
		position: absolute;
		top: 0;
		left: 0;
		z-index: 0;
	}

	.account {
		width: 100%;
		display: flex;
		justify-content: space-between;

		.a_left {
			padding: 10rpx 0 0 40rpx;
			display: flex;
			z-index: 1;

			.al_avatar {
				width: 120rpx;
				height: 120rpx;
				border-radius: 50%;
				background: #FFFFFF;
				padding: 4rpx;
				box-sizing: border-box;

				image {
					width: 100%;
					height: 100%;
					border-radius: 50%;
				}
			}

			.al_name_edit {
				margin-left: 30rpx;
				display: flex;
				flex-direction: column;

				&>text {
					font-size: 36rpx;
					font-family: PingFang-SC, PingFang-SC;
					font-weight: bold;
					color: #111111;
					line-height: 50rpx;
					padding-top: 4rpx;
				}

				.ane_edit {
					width: 120rpx;
					height: 54rpx;
					border-radius: 27rpx;
					border: 1rpx solid #D3D7DE;
					margin-top: 10rpx;
					display: flex;
					align-items: center;
					justify-content: center;

					&>text {
						font-size: 26rpx;
						font-family: PingFangSC, PingFang SC;
						font-weight: 400;
						color: #5A697C;
						line-height: 37rpx;
					}

					&>image {
						margin-left: 8rpx;
						width: 24rpx;
						height: 24rpx;
					}
				}
			}
		}

		.a_right {
			width: 79rpx;
			height: 137rpx;
			position: relative;

			&>image {
				width: 100%;
				height: 100%;
			}

			&>view {
				width: 123rpx;
				height: 45rpx;
				background: linear-gradient(270deg, #DAF9F2 0%, #FFFFFF 100%);
				box-shadow: 0rpx 4rpx 6rpx 0rpx rgba(0, 119, 80, 0.1);
				border-radius: 23rpx 0rpx 0rpx 23rpx;
				font-size: 24rpx;
				font-family: PingFangSC, PingFang SC;
				font-weight: 400;
				color: #007466;
				text-align: center;
				line-height: 45rpx;
				position: absolute;
				right: 0;
				bottom: -16rpx;
				z-index: 1;
			}
		}
	}

	.box {
		width: calc(100% - 40rpx);
		margin: 0 20rpx;
		box-sizing: border-box;
		background: #FFFFFF;
		border-radius: 20rpx;
		position: relative;
	}

	.nums {
		margin-top: 47rpx;
		padding: 35rpx 21rpx;
		box-sizing: border-box;
		display: flex;
		align-items: center;
		justify-content: space-around;

		&>view {
			width: 25%;
			display: flex;
			flex-direction: column;
			align-items: center;
			z-index: 1;

			text {
				font-size: 36rpx;
				font-family: PingFang-SC, PingFang-SC;
				font-weight: bold;
				color: #333333;
				line-height: 36rpx;

				&:last-child {
					font-size: 24rpx;
					font-family: PingFangSC, PingFang SC;
					font-weight: 400;
					color: #5A697C;
					line-height: 24rpx;
					margin-top: 20rpx;
				}
			}
		}
	}

	.wallet {
		margin-top: 32rpx;
		padding: 34rpx 40rpx 30rpx 31rpx;
		background: url(https://i.ringzle.com/file/20240129/062264cb5e224845b86e4567c2ec37a6.png) no-repeat;
		background-size: 100% 100%;
		display: flex;
		justify-content: space-between;

		.w_left {
			.wl_top {
				display: flex;
				align-items: center;

				image {
					width: 30rpx;
					height: 30rpx;
				}

				text {
					margin-left: 12rpx;
					font-size: 26rpx;
					font-family: PingFangSC, PingFang SC;
					font-weight: 400;
					color: #FFFFFF;
					line-height: 37rpx;
				}
			}

			.wl_price {
				margin-top: 17rpx;

				.wlp_span {
					font-size: 36rpx;
					font-family: DINAlternate, DINAlternate;
					font-weight: bold;
					color: #FFFFFF;
					line-height: 42rpx;
				}

				text {
					font-size: 48rpx;
					font-family: DINAlternate, DINAlternate;
					font-weight: bold;
					color: #FFFFFF;
					line-height: 56rpx;
					margin-left: 10rpx;
				}
			}
		}

		.w_right {
			margin-top: 16rpx;
			width: 164rpx;
			height: 72rpx;
			background: linear-gradient(270deg, #D6F6ED 0%, #FFFFFF 100%);
			border-radius: 36rpx;
			line-height: 72rpx;
			text-align: center;
			font-size: 26rpx;
			font-family: PingFang-SC, PingFang-SC;
			font-weight: bold;
			color: #007750;
		}
	}

	.orders {
		margin-top: 20rpx;
		padding: 40rpx 0;

		.o_title {
			width: 100%;
			padding: 0 20rpx;
			box-sizing: border-box;
			display: flex;
			align-items: center;
			justify-content: space-between;

			&>text {
				font-size: 36rpx;
				font-family: PingFang-SC, PingFang-SC;
				font-weight: bold;
				color: #1C1E41;
				line-height: 36rpx;
			}

			.ot_all {
				display: flex;
				align-items: center;

				&>text {
					font-size: 28rpx;
					font-family: PingFangSC, PingFang SC;
					font-weight: 400;
					color: #808080;
					line-height: 28rpx;
				}

				&>image {
					margin-left: 8rpx;
					width: 24rpx;
					height: 24rpx;
				}
			}
		}

		.o_menus {
			margin-top: 44rpx;
			display: flex;
			align-items: center;
			justify-content: space-around;

			&>view {
				width: 25%;
				display: flex;
				flex-direction: column;
				align-items: center;

				image {
					width: 54rpx;
					height: 54rpx;
				}

				text {
					font-size: 26rpx;
					font-family: PingFangSC, PingFang SC;
					font-weight: 400;
					color: #111111;
					line-height: 26rpx;
					margin-top: 24rpx;
				}
			}
		}
	}

	.services {
		margin-top: 20rpx;
		padding: 40rpx 10rpx 12rpx;

		.s_title {
			font-size: 36rpx;
			font-family: PingFang-SC, PingFang-SC;
			font-weight: bold;
			color: #1C1E41;
			line-height: 36rpx;
			padding-left: 10rpx;
		}

		.s_more {
			width: 100%;
			margin-top: 8rpx;

			.scroll-list {
				display: flex;
			}

			.sm_card {
				display: flex;
				flex-wrap: wrap;

				&>view {
					width: 25%;
					display: flex;
					flex-direction: column;
					align-items: center;
					margin-top: 40rpx;

					image {
						width: 48rpx;
						height: 48rpx;
					}

					text {
						font-size: 26rpx;
						font-family: PingFangSC, PingFang SC;
						font-weight: 400;
						color: #333333;
						line-height: 26rpx;
						margin-top: 24rpx;
					}
				}
			}
		}
	}
}
</style>